import java.util.*;
import java.io.*;
public class Main{
    public static void main()throws IOException{
        //BufferedReader从字符流中读取文本并缓存
        BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
        //n为字符流中文本（单词）个数
        int n=Integer.parseInt(re.readLine());
        //把读取到的单词放入字符串中
        String[] str=new String[n];
        for(int i=0;i<n;i++){
            str[i]=re.readLine();
        }
        if(isSortZidian(str)&&isSortLength(str)){
            System.out.println("both");
        }else if(isSortZidian(str)){
            System.out.println("lexicographically");
        }else if(isSortLength(str)){
            System.out.println("lengths");
        }else{
            System.out.println("none");
        }
    }
    public static boolean isSortZidian(String[] str){
        for(int i=0;i<str.length-1;i++){
            if(str[i].compareTo(str[i+1])>0) {
                return false;
            }
        }
        return true;
    }
    public static boolean isSortLength(String[] str){
        for(int i=0;i<str.length-1;i++){
            if(str[i].length()>str[i+1].length()){
                return false;
            }
        }
        return true;
    }
}
